<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户大屏元素')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            用户名：<input type="text" name="userName"/>
                        </li>
                        <li>
                            大屏名称：<input type="text" name="visualName"/>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                        </li>
                        <li>
                            <label>数据模型： </label>
                            <input onfocus="showDataModel()" autocomplete="off" id="modelName" name="modelName" class="form-control" type="text" required>
                            <input id="moduleIds" autocomplete="off" name="moduleIds" class="form-control" type="hidden" required>
                        </li>
                        <li>
                            <div th:object="${visualModule}">
                                <input th:field="*{baseId}" class="form-control" readonly="readonly" type="hidden" name="baseId"/>
                                <input th:field="*{moduleId}" class="form-control" readonly="readonly" type="hidden" name="moduleId"/>
                            </div>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:userModel:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:userModel:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:role:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
    var prefix = ctx + "system/userModel";


    function showDataModel() {
        $.modal.open("选择数据模型", prefix + "/showDataModel");
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            //sortName: "roleSort",
            modalName: "用户大屏元素",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户名',
                    sortable: true
                },
                {
                    field: 'visualName',
                    title: '大屏名称',
                    sortable: true
                },
                {
                    field: 'modelName',
                    title: '模型名称',
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateName',
                    title: '更新人名称',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    // width: '30%',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="updateData(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改数据</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showJson(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看样式JSON</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function updateData(id){

        $.modal.open("修改数据",prefix+"/editDataRule/"+id)
    }

    function checkJson(id){

        $.modal.open("查看样式JSON",prefix+"/checkJson/"+id)
    }

    function showJson(id) {

        var width = 800;
        var height = ($(window).height() - 50);

        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: "查看样式JSON",
            content: prefix +  "/showCssJson/"  + id,
            btn: [ '关闭'],
            // 弹层外区域关闭
            shadeClose: true
        })
    }


</script>

</body>
</html>